import config from './config'
export default function request(url, data, method = GET) {
  return new Promise((resolve, reject) => {
    wx.request({
      url: 'http://localhost:3000/' + url,
      data,
      header:{
        cookie:wx.getStorageSync('cookie').join(';')
      },
      method,
      success: (res) => {
        if(data.islogin){
          console.log(res,'请求回来的数据');
          //请求回来的cookie是一个数组,要把数组拼接成字符串
          wx.setStorageSync('cookie', res.cookies)
        }
        resolve(res.data)
      },
      fail: (err) => {
        reject(err)
      }
    })
  })
}